<include file="Common:header"/>
<style>
  .article-list-box{padding:0px 10px;padding-bottom:10px;margin-top:15px;} 
  .home_text{height:50px;} 
  .article-list-title{height:40px;line-height: 40px;width:100%;border-bottom:1px solid #e6e6e6;border-top:1px solid #e6e6e6;overflow: hidden;font-size:15px;text-overflow: ellipsis;white-space: nowrap;}
  .article-list-condition{border-bottom:1px solid #e6e6e6;height:40px;width:100%;line-height:40px;font-size:15px;}
  .article-list-packet{border-bottom:1px solid #e6e6e6;height:50px;width:100%;line-height:20px;font-size:15px;}
  .article-list-button{border-bottom:1px solid #e6e6e6;height:40px;width:100%;line-height:40px;}
  .article-list-button-left{height:40px;float:left;width:50%;border-right:1px solid #e6e6e6;text-align:center;line-height: 40px}
  .article-list-button-right{height:40px;float:left;width:49%;text-align: center;line-height: 40px}
  .button{background-color:#4084bb;font-size:13px;border-radius:8px;padding:5px 20px;color:#fff;}
  .header .back {
    background-image: url(__PUBLIC__/img/back.png);
    background-size: 10px 15px;
    background-repeat: no-repeat;
    background-position: 0px 18px;
    line-height: 30px;
    vertical-align: top;
    margin: 0 0 0 5px;
    font-size: 16px;
    padding-left: 15px;
  }
  .header a {
    position: absolute;
    display: inline-block;
    height: 30px;
    padding: 10px;
    color: #fff;
  }
  .header .btn {
    line-height: 30px;
    vertical-align: top;
    margin: 0 0 0 5px;
    font-size: 16px;
    padding-left: 15px;
  }
  .header a.right{
  	right:0px;
  }
</style>
<body>
	<div class="header">
		快速链接管理
		<a href="javascript:history.back();" class="left back">
			<i class="icon-back"></i>返回
		</a>
		<a href="<{:U('Home/Quicklink/create_quick_link')}>" class="right btn">
	        创建
	    </a>
	</div>
	<div class="main-wrap" style="padding-top:10px;">
	<if condition = "!empty($result)">
		<foreach name="result" item="row">
			<div class="task">
				<div class="article-list-box">
					<div class="article-list-title" style="border-bottom:0px;">
						链接名称：<{$row['title']}>
					</div>
					<div class="article-list-title" style="">
						链接URL：<{$row['link']}>
					</div>
					<div class="article-list-button">
					  <a href="<{:U('create_quick_link',array('link_id'=>$row['id']))}>">
						<div class="article-list-button-left">
							<button type="button" class="button">
								链接修改
							</button>
						</div>
					  </a>
					  <a href="javascript:void(0)" onclick="delete_link(this)" data-link-id="<{$row['id']}>">
						<div class="article-list-button-right">
							<button type="button" class="button">
								链接删除
							</button>
						</div>
					  </a>
					</div>
				  </div>
			</div>
			<div class="grey-hr mg-b-5"></div>
		</foreach>
	<else />
		<div class="mg-b-15" style="text-align:center;font-size:20px">～暂无数据～</div>
	</if>
		<div id="loadding" style="text-align: center; display: none;">
			<img src="__PUBLIC__/js/layer/skin/default/loading-0.gif" />
		</div>
	</div><!-- end:main-wrap -->
	<input type="hidden" id="page" value="1">

	<include file="Common:menu"/>

</body>
</html>
<script>
$(function(){
	$(window).scroll(function () {
		if($(window).scrollTop()>=($(document).height()-$(window).height())){
			ajax_article();
		}
	});
});


//加载文章
function ajax_article(){
	var loadObj = $('#loadding');
	var page = $('#page').val();
	if(page == '-1'){
		return false;
	}
	loadObj.show();
	$.ajax({
		type: "POST",
		url: "<{:U('Home/Quicklink/ajax_quick_link_list')}>",
		data: "page="+page,
		dataType:'json',
		success: function(msg){
			if(msg.status == '1'){
				var html = '';
				for(var i  in  msg.data){
					html +='<div class="task">';
					html +='<div class="article-list-box">';
					html +='<div class="article-list-title" style="border-bottom:0px;">';
					html +='链接名称：'+msg.data[i].title+'';
					html +='</div>';
					html +='<div class="article-list-title">';
					html +='链接URL：'+msg.data[i].link+'';
					html +='</div>';
					html +='<div class="article-list-button">';
					html +='<a href="'+msg.data[i].url+'">';
					html +='<div class="article-list-button-left"><button type="button" class="button">链接修改</button></div></a>';
					html +='<a href="javascript:void(0)" onclick="delete_link(this)" data-link-id="'+msg.data[i].id+'">';
					html +='<div class="article-list-button-right">';
					html +='<button type="button" class="button">链接删除</button></div></a></div></div></div>';
					html +='<div class="grey-hr mg-b-5"></div>';
				}
				page = parseInt(page) + 1;
				$('#page').val(page);
				$('#loadding').before(html);
				loadObj.hide();
			}else{
				$('#page').val('-1');
				loadObj.hide();
			}
		}
	});
}

//删除文章
function delete_link(obj){
	var delete_id = $(obj).attr('data-link-id');
		
	layer.open({
		content: '您确定删除链接吗？',
		btn: ['确认', '取消'],
		shadeClose: false,
		yes: function(){
			$.ajax({
				type: "POST",
				url: "<{:U('Home/Quicklink/ajax_delete_link')}>",
				data: "delete_id="+delete_id,
				success: function(msg){
					open_layer(msg);
				}
			});
		}
	});	
}

</script>
